package com.heo.pub;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

public class ClientConfig
{
  private static Logger log = Logger.getLogger(ClientConfig.class);

  public static int READ_IDLE_TIME = 0;// 心跳消息读超时
  public static int WRITE_IDLE_TIME = 0;// 心跳消息写超时
  public static int ALL_IDLE_TIME = 0;// 心跳消息读写超时
  public static String SERVER_IP = "127.0.0.1";
  public static int PORT = 9999;// 监听端口号
  public static int RECONNECT_TIME = 3000;//重连时间
  public static int CONNECT_TIME = 1000;//请求超时时间

  static
  {
    Properties props = new Properties();
    FileInputStream is = null;
    try
    {
//      is = new FileInputStream(ServerConfig.class.getResource("/").getPath() + "/com/heo/config/client.properties");
      is = new FileInputStream("/client.properties");
      props.load(is);
      READ_IDLE_TIME = Integer.valueOf(new String(props.getProperty("ReadIdleTime").getBytes("ISO8859-1"), "UTF-8"));
      WRITE_IDLE_TIME = Integer.valueOf(new String(props.getProperty("WriteIdleTime").getBytes("ISO8859-1"), "UTF-8"));
      ALL_IDLE_TIME = Integer.valueOf(new String(props.getProperty("AllIdleTime").getBytes("ISO8859-1"), "UTF-8"));
      SERVER_IP = new String(props.getProperty("ServerIp").getBytes("ISO8859-1"), "UTF-8");
      PORT = Integer.valueOf(new String(props.getProperty("Port").getBytes("ISO8859-1"), "UTF-8"));
      RECONNECT_TIME = Integer.valueOf(new String(props.getProperty("ReconnectTime").getBytes("ISO8859-1"), "UTF-8"));
      CONNECT_TIME = Integer.valueOf(new String(props.getProperty("ConnectTime").getBytes("ISO8859-1"), "UTF-8"));
    }
    catch (IOException e)
    {
      log.error(e.getMessage(), e);
    }
    finally
    {
      if (is != null)
      {
        try
        {
          is.close();
        }
        catch (IOException e)
        {
          log.error(e.getMessage(), e);
        }
      }
    }
  }

  /**
   * @param args
   */
  public static void main(String[] args)
  {
    // TODO Auto-generated method stub
  }

}
